Ext.define('Risk.view.window.Project', {
    extend: 'Ext.window.Window',
    alias: 'widget.project',
    title: '添加项目信息',
    layout: 'fit',
    parentname:'区域信息',
    modal:true,
    pid:null,
    treeStore1:null,
    index:0,
    initComponent: function() {
        this.items = [{
        	xtype:'form',
        	layout: 'anchor',
        	buttonAlign:'center',
        	url:'project/addproject.do',
        	frame:true,
        	defaults:{
        	     anchor: '100%'
        	 },
        	 items:[
					{
						 margin:'0 0 0 10',
						 xtype:'textfield',
						 fieldLabel: '项目所属区域',
						 value:this.parentname,
						 name:'parentname',
						 disabled:true
					},
					{
						 margin:'0 0 0 10',
						 xtype:'hidden',
						 name:'pid',
						 value:this.pid
					},
					{
						 xtype:'hidden',
						 name:'id',
						 value:null
					},
					{
						 margin:'0 0 0 10',
						 xtype:'textfield',
						 fieldLabel: '项目名称',
						 name: 'name',
						 allowBlank: false
					},
					{
						   margin:'0 0 0 10',
				           forceSelection:true,
				            xtype:'combo',
				            store:'areaStore.TypeStore',
				            fieldLabel:'对象类型',
				            allowBlank:false,
				            blankText:'对象类型不能为空！',
				            displayField: 'name',
				            valueField:'value',
				            name:'type'
					},
					{
						 margin:'0 0 0 10',
						 xtype:'textfield',
						 fieldLabel: '对象名称',
						 name: 'objname'
					}
			],
			buttons:[
			        {
			        	text:'保存',
			        	handler:function()
			        	{
			        		  var obj =  this.up('project');
			        		  var form = this.up('form').getForm();
			                  if (form.isValid()) {
			                      // Submit the Ajax request and handle the response
			                      form.submit({
			                          success: function(o, action) {
			                        	  Ext.Msg.alert('Success', action.result.message);
			                              obj.treeStore1.load();
			                              obj.close();
			                          },
			                          failure: function(form, action) {
			                              Ext.Msg.alert('Failed', action.result ? action.result.message : 'No response');
			                          }
			                      });
			                  }
			        	}
			        },
			        {
			        	text:'取消',
			        	handler:function(ojb)
			        	{
			        		this.up('project').close();
			        	}
			        } 
			]
        }];
        this.callParent(arguments);
    }
});